<template>
	<view class="content">
		<view class="address" v-for="(item, index) in players" :key="index">
			<text class="address-tlt" style="margin-bottom: 24rpx">参赛人{{ index + 1 }}</text>
			<view class="user">
				<u-cell-group :border="false">
					<u-cell title="姓名" :border="false" :value="item.playerName"> </u-cell>
					<u-cell title="性别" :border="false" :value="item.playerSex == 1 ? '男' : '女'"></u-cell>
					<u-cell
						title="选手类型"
						:border="false"
						:value="item.playerType == 1 ? '成人' : '儿童'"
					></u-cell>
					<u-cell
						title="证件类型"
						:border="false"
						:value="item.playerCid == 1 ? '身份证' : '护照'"
					></u-cell>
					<u-cell title="证件号" :border="false" :value="item.playerCidNo"></u-cell>
					<u-cell title="手机号" :border="false" :value="item.playerMobile"></u-cell>
					<u-cell title="年龄" :border="false" :value="item.playerAge"></u-cell>
					<u-cell title="生日" :border="false" :value="item.playerBorn"></u-cell>
					<!-- <u-cell title="血型" :border="false" :value="item.playerBlood"></u-cell>
					<u-cell
						title="衣服尺码"
						:border="false"
						:value="item.playerClothes"
						v-if="item.playerClothes"
					></u-cell> -->
				</u-cell-group>
			</view>
		</view>

		<view class="footer">
			<button class="footer-btn" @click="onSubmit">返回</button>
		</view>
	</view>
</template>

<script>
const app = getApp()
export default {
	data() {
		return {
			id: '',
			info: {},
			players: [],
			isLock: false
		}
	},
	async onLoad(options) {
		const eventChannel = this.getOpenerEventChannel()
		if (!eventChannel) return
		eventChannel.on('sendData', (data) => {
			this.players = data
		})
	},
	methods: {
		getDetailInfo(id) {
			/* prettier-ignore */
			this.$https( true, 'post', {
				url:'/race/race/info/'+this.info.cid,
				data: {}
			},(res) => {
				this.detailInfo = res.data
				console.log(this.orderSteps)
			})
			/* prettier-ignore */
		},

		async useWxPay() {
			const openid = await loginHandle()
			this.$https(
				true,
				'post',
				{
					url: '/order/order/pay',
					data: {
						openId: openid,
						raceId: this.info.cid
					}
				},
				(res) => {
					console.log(res)
					uni.requestPayment({
						provider: 'wxpay',
						appId: appid,
						timeStamp: res.data.timeStamp, //当前的时间
						nonceStr: res.data.nonceStr, //随机字符串
						package: 'prepay_id=' + res.data.prepayId,
						signType: 'MD5', //签名算法，暂支持 MD5。
						paySign: res.data.paySign, //签名
						success: (pay) => {
							uni.$u.toast('报名成功！')
							setTimeout(() => {
								uni.redirectTo({
									url: '/pagesA/sign/payResult?type=success'
								})
								this.isLock = false
							}, 1500)
						},
						fail: (error) => {
							console.log('失败', error)
							uni.$u.toast('支付失败，请重试！')
							setTimeout(() => {
								this.isLock = false
							}, 2000)
						}
					})
				},
				(error) => {
					setTimeout(() => {
						this.isLock = false
					}, 1000)
				}
			)
		}
	}
}
</script>

<style lang="scss" scoped>
.content {
	width: 100%;
	padding: 0 0 130rpx;
	position: relative;
}
.address {
	padding: 24rpx 28rpx;
	width: calc(702rpx - 56rpx);
	overflow-x: hidden;
	background-color: #fff;
	border-radius: 16rpx;
	margin: 0 auto 24rpx;
	&-tlt {
		font-size: 28rpx;
		color: #898989;
		border-bottom: 1px solid #e9e9e9;
		display: block;
		padding-bottom: 18rpx;
		&:before {
			display: inline-block;
			content: '';
			width: 8rpx;
			height: 30rpx;
			float: left;
			margin: 4rpx 10rpx 0;
			background-color: #0071c5;
		}
	}
}
.tips {
	background-color: #d4f0ff;
	font-size: 26rpx;
	color: #0071c5;
	padding: 16rpx 20rpx;
	line-height: 36rpx;
	margin: 12rpx 6rpx 10rpx;
}
.footer {
	width: calc(100% - 48rpx);
	padding: 0 24rpx;
	height: 120rpx;
	background-color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	position: fixed;
	bottom: 0;
	z-index: 9;
	border-top: 1px solid #e5e5e5;
	&-btn {
		width: 684rpx;
		height: 80rpx;
		background-color: #0071c5;
		border: 1px solid #0071c5;
		border-radius: 16rpx;
		font-size: 30rpx;
		color: #fff;
		margin: 0;
	}
}
::v-deep {
	.u-cell .u-cell__body {
		padding: 6rpx 12rpx;
		.u-cell__title-text {
			font-size: 28rpx;
			color: #898989;
			min-width: 200rpx;
		}
		.u-cell__value {
			font-size: 28rpx;
			font-weight: 500;
			color: #231815;
		}
	}
	.u-button {
		margin: 0;
	}
}
</style>
